﻿<UserControl x:Class="DaxStudio.UI.Views.StatusBarView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:avalondock="http://schemas.xceed.com/wpf/xaml/avalondock"
             mc:Ignorable="d" 
             d:DesignHeight="24" d:DesignWidth="400">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
        <BitmapImage x:Key="StatusSpid"  UriSource="..\images\status-spid.png"></BitmapImage>
        <BitmapImage x:Key="StatusPos"  UriSource="..\images\status-pos.png"></BitmapImage>
        <BitmapImage x:Key="StatusServer"  UriSource="..\images\status-server.png"></BitmapImage>
        <SolidColorBrush x:Key="SpinnerColorBrush" Color="White"></SolidColorBrush>
        <Storyboard x:Key="Rotation">
            
            <DoubleAnimation Storyboard.TargetName="rotateTransform"
                       Storyboard.TargetProperty="Angle"
                       From="0" To="360" Duration="00:00:01"
                       RepeatBehavior="Forever"/>
        </Storyboard>
        
        <ControlTemplate x:Key="Spinner">
            <Grid Name="LayoutRoot" RenderTransformOrigin="0.5,0.5">
                <Grid.RenderTransform>
                    <TransformGroup>
                        <RotateTransform x:Name="rotateTransform"/>
                    </TransformGroup>
                </Grid.RenderTransform>
                <Ellipse Fill="{DynamicResource SpinnerColorBrush}">
                    <Ellipse.OpacityMask>
                        <ImageBrush ImageSource="../Images/SpinnerMask.png" Stretch="None"/>
                    </Ellipse.OpacityMask>
                </Ellipse>
                <Grid.OpacityMask>
                    <RadialGradientBrush>
                        <GradientStop Color="Black" Offset="0.96"/>
                        <GradientStop Color="Transparent" Offset="0.959"/>
                    </RadialGradientBrush>
                </Grid.OpacityMask>
            </Grid>
        </ControlTemplate>
        <Color x:Key="DisabledForegroundColor">#FF888888</Color>
        <!--
        <Style x:Key="{x:Type StatusBar}"
       TargetType="{x:Type StatusBar}">
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="OverridesDefaultStyle" Value="true" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type StatusBar}">
                        <Border Padding="1">
                            
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0"
                                 EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStopCollection>
                                            <GradientStop Color="{DynamicResource BorderLightColor}"
                                Offset="0.0" />
                                            <GradientStop Color="{DynamicResource BorderDarkColor}"
                                Offset="1.0" />
                                        </GradientStopCollection>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0"
                                 EndPoint="0,1">
                                    <LinearGradientBrush.GradientStops>
                                        <GradientStopCollection>
                                            <GradientStop Color="{DynamicResource ControlLightColor}"
                                Offset="0.0" />
                                            <GradientStop Color="{DynamicResource ControlMediumColor}"
                                Offset="1.0" />
                                        </GradientStopCollection>
                                    </LinearGradientBrush.GradientStops>
                                </LinearGradientBrush>

                            </Border.Background>
                            
                            <ItemsPresenter />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    -->

        <Style x:Key="{x:Static StatusBar.SeparatorStyleKey}"
       TargetType="{x:Type Separator}">
            <Setter Property="OverridesDefaultStyle"
          Value="True" />
            <Setter Property="SnapsToDevicePixels"
          Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Separator}">
                        <Rectangle Width="1"
                   Margin="3">
                            <Rectangle.Fill>
                                <SolidColorBrush Color="#00000000" />
                            </Rectangle.Fill>
                        </Rectangle>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="{x:Type StatusBarItem}" TargetType="{x:Type StatusBarItem}">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type StatusBarItem}" >
                        
                        <ContentPresenter Margin="3" Name="ContentSite" />
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled"
                   Value="false">
                                <Setter Property="Foreground">
                                    <Setter.Value>
                                        <SolidColorBrush Color="{StaticResource DisabledForegroundColor}" />
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="IsEnabled"
                   Value="true">
                                <Setter Property="Foreground">
                                    <Setter.Value>
                                        <SolidColorBrush Color="White" />
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>
    <Grid >
        <StatusBar >
            <StatusBar.ItemsPanel >
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="20" />
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem Grid.Column="0">
                <StackPanel Orientation="Horizontal">
                <!--    <ContentControl x:Name="Spinner"></ContentControl> -->
                    <Grid Name="LayoutRoot" RenderTransformOrigin="0.5,0.5" Width="14" Height="14" Visibility="{Binding Working, Converter={StaticResource BoolToVisibilityConverter}}">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <RotateTransform x:Name="rotateTransform"/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Ellipse Fill="{DynamicResource SpinnerColorBrush}">
                            <Ellipse.OpacityMask>
                                <ImageBrush ImageSource="../Images/SpinnerMask.png" Stretch="None"/>
                            </Ellipse.OpacityMask>
                        </Ellipse>
                        <Grid.OpacityMask>
                            <RadialGradientBrush>
                                <GradientStop Color="Black" Offset="0.96"/>
                                <GradientStop Color="Transparent" Offset="0.7"/>
                            </RadialGradientBrush>
                        </Grid.OpacityMask>
                        <Grid.Triggers>
                            <EventTrigger RoutedEvent="Window.Loaded">
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="rotateTransform"
                                            Storyboard.TargetProperty="Angle"
                                            From="0" To="360" Duration="00:00:01"
                                            RepeatBehavior="Forever"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger>
                        </Grid.Triggers>
                    </Grid>
                </StackPanel>
            </StatusBarItem>
            <Separator Grid.Column="1"/>
            <StatusBarItem Grid.Column="2">
                    <!--<ProgressBar Orientation="Horizontal" Visibility="Visible" IsIndeterminate="True" Width="55" Height="15" />-->
                
                <TextBlock x:Name="Message1" Text="{Binding ActiveDocument.StatusBarMessage}" ></TextBlock>
                
            </StatusBarItem>
            <Separator Grid.Column="3"/>
            <StatusBarItem Grid.Column="4">
                <StackPanel Orientation="Horizontal">
                    <!--<Image Source="{StaticResource StatusPos}"></Image>-->
                    <TextBlock  x:Name="PositionText">1, 1</TextBlock>
                </StackPanel>
                <StatusBarItem.ToolTip>
                    <TextBlock>Current position in Editor</TextBlock>
                </StatusBarItem.ToolTip>
            </StatusBarItem>
            <Separator Grid.Column="5"/>
            <StatusBarItem Grid.Column="6" >
                <StackPanel Orientation="Horizontal">
                    <Image Source="{StaticResource StatusServer}"></Image>
                    <TextBlock x:Name="ServerName">Server</TextBlock>
                </StackPanel>
                <StatusBarItem.ToolTip>
                    <TextBlock>Server name</TextBlock>
                </StatusBarItem.ToolTip>
            </StatusBarItem>
            <Separator Grid.Column="7"/>
            <StatusBarItem Grid.Column="8">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{StaticResource StatusSpid}"></Image>
                <TextBlock x:Name="Spid">SPID</TextBlock>
                </StackPanel>
                <StatusBarItem.ToolTip>
                    <TextBlock>Connection SPID</TextBlock>
                </StatusBarItem.ToolTip>
            </StatusBarItem>
            <Separator Grid.Column="9"/>
            <StatusBarItem Grid.Column="10">
                <TextBlock x:Name="TimerText">0:00:00.00</TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</UserControl>
